#include "sqlite.hpp"
#include <cassert>
#include <vector>
int SelectCallback(void* arg, int n, char** result, char** fields)
{
    std::vector<std::string>* v = static_cast<std::vector<std::string>*>(arg);
    v->push_back(result[0]);
    return 0;
}
int main()
{
    SqliteHelper s("test.db");
    s.open();
    // const char* sql = "create table stu(sn int, name varchar(8), age int);";
    // assert(s.exec(sql, nullptr, nullptr));
    // const char* insert_sql = "insert into stu values(1, '小明', 19), (2, '小红', 20), (3, '小黑', 10);";
    // assert(s.exec(insert_sql, nullptr, nullptr));
    // const char* update_sql = "update stu set age = 10 where sn = 2;";
    // assert(s.exec(update_sql, nullptr, nullptr));
    // const char* delete_sql = "delete from stu where sn = 2;";
    // assert(s.exec(delete_sql, nullptr, nullptr));
    const char* select_sql = "select name from stu;";
    std::vector<std::string> res;
    assert(s.exec(select_sql, SelectCallback, &res));
    for(auto name : res) std::cout << name << std::endl;
    return 0;
}